using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using LightCAD.Runtime;

namespace LightCAD.UI;

public partial class Toolbar : UserControl
{
    public Toolbar()
    {
        InitializeComponent();

        this.btnOpen.Click += BtnOpen_Click;
        this.btnSave.Click += BtnSave_Click;

        this.btnCopy.Click += BtnCopy_Click;
        this.btnCut.Click += BtnCut_Click;
        this.btnPaste.Click += BtnPaste_Click;

        this.btnRedo.Click += BtnRedo_Click;
        this.btnUndo.Click += BtnUndo_Click;

        this.btnDrawCircleCR.Click += BtnDrawCircleCR_Click;
        this.btnDrawLine2P.Click += BtnDrawLine2P_Click;
        this.btnDrawCircle2P.Click += BtnDrawCircle2P_Click;
        this.btnShowFloatBlock.Click += BtnShowFloatBlock_Click;


        this.btnSettings.Click += BtnSettings_Click;
        this.btnSettings2.Click += BtnSettings2_Click;
    }

    private void BtnSettings2_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        //VPort.DrawingControl.IsStopRenderLoop = true;
        VPort.DrawingControl.RequestRender();
    }

    private void BtnSettings_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        //VPort.DrawingControl.IsStopRenderElements = true;
    }

    private void BtnUndo_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        Commands.Undo();
    }

    private void BtnRedo_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        Commands.Redo();
    }

    private void BtnOpen_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        Commands.Open();
    }

    private void BtnPaste_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        Commands.Paste();

    }

    private void BtnCut_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        Commands.Cut();

    }

    private void BtnCopy_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        Commands.Copy();
    }

    private void BtnSave_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        Commands.Save();
    }

    private void BtnShowFloatBlock_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        VPort.IsShowFloatBlock = !VPort.IsShowFloatBlock;
    }

    private void BtnDrawCircle2P_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        Commands.DrawCircle2P(null);
    }

    private void BtnDrawLine2P_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        Commands.DrawLine2P(null);
    }

    private void BtnDrawCircleCR_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
    {
        Commands.DrawCircleCR(null);
    }
}